package com.hj.system.system.shiro;

import lombok.Data;
import org.apache.shiro.authc.UsernamePasswordToken;

import java.io.Serializable;

@Data
public class UserNameLoginToken extends UsernamePasswordToken implements Serializable {
    /**
     * 登陆类型
     */
    private String loginType;

    public UserNameLoginToken() {
        super();
    }

    public UserNameLoginToken(final String username, final String password) {
        super(username, password);
    }

    /**
     * 是否需要密码校验
     */
    private boolean requriedPassword;

    public static UserNameLoginToken buildNoPassword(String username, String loginType) {
        UserNameLoginToken userNameLoginToken = new UserNameLoginToken();
        userNameLoginToken.setUsername(username);
        userNameLoginToken.setLoginType(loginType);
        userNameLoginToken.setRequriedPassword(false);
        return userNameLoginToken;
    }

    public static UserNameLoginToken buildPassword(String username, String password, String loginType) {
        UserNameLoginToken userNameLoginToken = new UserNameLoginToken(username, password);
        userNameLoginToken.setLoginType(loginType);
        userNameLoginToken.setRequriedPassword(true);
        return userNameLoginToken;
    }
}
